<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#div1 {width:100px; height:100px; background:#CCC; position:absolute;}
</style>
<script>
document.onkeydown=function (ev)
{
	var oEvent=ev||event;
	var oDiv=document.getElementById('div1');
	
	if(oEvent.keyCode==37)
	{
		oDiv.style.left=oDiv.offsetLeft-10+'px';
	}
	else if(oEvent.keyCode==39)
	{
		
		oDiv.style.left=oDiv.offsetLeft+10+'px';
	}
};
</script>
</head>

<body>
<div id="div1"></div>
</body>
</html>
